<template>
	<view>
		<!-- 进度条 -->
		<view class="od-banner">
		    <image class="od-banner-icon" src="/static/resource/images/od_bg_icon.png" mode="widthFix" />
		    <view class="od-jd od-jd-0">
		        <view class="od-jd-out">
		            <view class="od-jd-in"></view>
		        </view>
		        <view class="vp-flex od-jd-text">
		            <view class="vp-flex_1">
		                <text class="od-jd-st-0">填写订单</text>
		            </view>
		            <view class="vp-flex_1">
		                <text class="od-jd-st-10">在线支付</text>
		            </view>
		            <view class="vp-flex_1">
		                <text class="od-jd-st-20">专人服务</text>
		            </view>
		            <view class="vp-flex_1">
		                <text class="od-jd-st-30">服务完成</text>
		            </view>
		        </view>
		    </view>
		</view>
		<!-- 服务内容 -->
		<view class="pub-box">
			<view class="pub-box-bd">
				<view class="weui-cell weui-cell_input">
					<view class="weui-cell__hd">
						<img
							class="serv-icon"
							:src="service.icon_image_url || '../../static/resource/images/avatar.jpg'"
						/>
					</view>
					<view class="weui-cell__bd">
						<text class="serv-name">{{service.name}}</text>
					</view>
					<view class="weui-cell__ft">
						<view 
							class="f5 ic_info" 
							@click="handleTap"
						>
							服务内容
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 陪诊服务表单 -->
		<block v-if="service.stype === '10' || service.stype === '15' || service.stype === '20'">
			<AccompanyForm 
				:service = "service" 
				:hospitals ="hospitals"
				:curHospital.sync = "curHospital"
				@changeHospital = "onHisChange"
			/>
		</block>
		<!-- 代跑服务表单 -->
		<block v-else-if="service.stype === '30' || service.stype === '40'">
			<PinchForm
				:service = "service"
				:hospitals ="hospitals"
				:curHospital.sync = "curHospital"
				@changeHospital = "onHisChange"
			/>
		</block>
		
	</view>
</template>

<script>
	import PinchForm from './components/pinch.vue'
	import AccompanyForm from './components/accompany.vue'
	export default {
		components:{PinchForm,AccompanyForm},
		data() {
			return {
				//页面详情数据
				service: {
				},
				//医院数据
				hospitals:[],
				//当前选中医院的信息
				curHospital:{
					//当前选中医院的id
					id:null,
					//当前选中医院的name
					name:'',
					service_price:'',
					service_id:''
				}
			}
		},
		onLoad({svid,hid}){
			this.loadData(svid,hid)
		},
		methods: {
			async loadData(svid,hid){
				const app = getApp()
				const {data} = await app.globalData.utils.request({
					url:'/Service/order',
					data: {svid}
				})
				this.service = data.service
				//console.log('stype',this.service.stype)
				this.hospitals = data.hospitals	
				const res = this.hospitals.find(item=>item.id === Number(hid))
				// console.log(this.service)
				// console.log(id,name,service_id)
				this.curHospital = {...res}
				
			},
			//服务内容弹框
			handleTap(){
				
			}
		}
	}
</script>

<style>
@import './index.css'
</style>
